package com.uplooking.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.uplooking.pojo.AddrVO;
import com.uplooking.service.CustService;

@RestController
public class CustController {

	@Autowired
	private CustService custService;
	
	@GetMapping(value="/cust/count/shopcar/{username}")
	public Object countShopCar(@PathVariable(name="username")String username) {
		return custService.countShopCar(username);
	}
	
	@GetMapping(value="/cust/add/shopcar/{username}/{gno}")
	public Object addShopCar(@PathVariable(name="username")String username,
			@PathVariable(name="gno")String gno) {
		return custService.addShopCar(username, gno);
	}
	
	@GetMapping(value="/cust/del/shopcar/{username}/{gno}")
	public Object delShopCar(@PathVariable(name="username")String username,
			@PathVariable(name="gno")String gno) {
		return custService.delShopCar(username, gno);
	}
	
	@GetMapping(value="/cust/list/shopcar/{username}")
	public Object delShopCar(@PathVariable(name="username")String username) {
		return custService.listShopCar(username);
	}
	
	@PostMapping(value="/cust/add/addr")
	public Object addAddr(String username,AddrVO addrVO) {
		return custService.addAddr(username, addrVO);
	}
	
	@GetMapping(value="/cust/del/addr/{username}/{id}")
	public Object delAddr(@PathVariable(name="username")String username,
			@PathVariable(name="id")String id) {
		return custService.delAddr(username, id);
	}
	
	@GetMapping(value="/cust/def/addr/{username}/{id}")
	public Object defAddr(@PathVariable(name="username")String username,
			@PathVariable(name="id")String id) {
		return custService.defAddr(username, id);
	}

	@GetMapping(value="/cust/list/addr/{username}")
	public Object listAddr(@PathVariable(name="username")String username) {
		return custService.listAddr(username);
	}
	
	@PostMapping(value="/cust/buy/order")
	public Object buyOrder(String username,String gno,String addrid,
			int count,String desc) {
		return custService.buyOrder(username, gno, addrid, count, desc);
	}
	
	@GetMapping(value="/cust/list/order/{username}")
	public Object listOrder(@PathVariable(name="username")String username) {
		return custService.listOrder(username);
	}
	
	@GetMapping(value="/cust/cancel/order/{username}/{ono}")
	public Object cancelOrder(@PathVariable(name="username")String username,
			@PathVariable(name="ono")String ono) {
		return custService.cancelOrder(username, ono);
	}
	
	@GetMapping(value="/cust/payfor/order/{username}/{ono}")
	public Object payForOrder(@PathVariable(name="username")String username,
			@PathVariable(name="ono")String ono) {
		return custService.payForOrder(username, ono);
	}
	
}
